#include "Node/LRG_Node_GridCell.h"
#include "Node/LRG_Node_ActorListFrequencyBuckets.h"

ULRG_Node_GridCell::ULRG_Node_GridCell()
	:Super()
{

}

int32 ULRG_Node_GridCell::GetCellId() const
{
	return Coordinate.ToId();
}

void ULRG_Node_GridCell::InitializeCell(ULRG_Node_GridSpatial* Grid, int32 CoordX, int32 CoordY)
{
	OwnerGrid = Grid;
	Coordinate.X = CoordX;
	Coordinate.Y = CoordY;
	Describe = FString::Printf(TEXT("GridCell_%d_%d"), Coordinate.X, Coordinate.Y);
	if(DynamicActorListFrequencyBucketsNode)
	{
		DynamicActorListFrequencyBucketsNode->SetCoordinate(Coordinate);
	}
	ComponentBuckets = CreateChildNode<ULRG_Node_ComponentBuckets>();
}

FString ULRG_Node_GridCell::GetDesc()
{
	if(Describe.IsEmpty())
	{
		Describe = FString::Printf(TEXT("GridCell_%d_%d"), Coordinate.X, Coordinate.Y);
	}
	return Describe;
}

void ULRG_Node_GridCell::GatherActorListsForConnection(const FConnectionGatherActorListParameters& Params)
{
	//Super::GatherActorListsForConnection(Params);
	ComponentBuckets->GatherActorListsForConnection(Params);
}

void ULRG_Node_GridCell::AddActor_Dynamic(ULineReplicationGraphComponent* Component)
{
	ComponentBuckets->AddNetworkActor(Component);
}

void ULRG_Node_GridCell::RemoveActor_Dynamic(ULineReplicationGraphComponent* Component)
{
	ComponentBuckets->RemoveNetworkActor(Component);
}

void ULRG_Node_GridCell::AddActor_Static(ULineReplicationGraphComponent* Component)
{
	
}